//
//  WLLVisitorViewController.swift
//  WLLWeibo
//
//  Created by 王乐乐 on 16/8/9.
//  Copyright © 2016年 itcast. All rights reserved.
//

import UIKit

class WLLVisitorViewController: UIViewController {

    //判断用户是否登录
    var isLogin : Bool = WLLUserAccountViewModel.shareTool.isLogin
    
    //访客视图
    var visitorView : WLLVisitorView?
    
    
    override func loadView() {
        if isLogin {
//            super.loadView()
            view = tableView
        }else{
            setupVisitorView()
        }
    }
     //MARK: - 设置访客视图
    func setupVisitorView ()  {
        setupNv()
        visitorView = WLLVisitorView()
        //实例化闭包
        visitorView?.closure = {
//            print("\(self)登录注册")
            self.loginAction()
        }
        
        view = visitorView
    }
    /**
     设置导航栏
     */
    func setupNv ()  {
        
        navigationItem.leftBarButtonItem = UIBarButtonItem(title: "注册", style: UIBarButtonItemStyle.Plain, target: self, action: #selector(WLLVisitorViewController.loginAction))
        
        navigationItem.rightBarButtonItem = UIBarButtonItem(title: "登录", style: UIBarButtonItemStyle.Plain, target: self, action: #selector(WLLVisitorViewController.loginAction))
        
    }
    
     //MARK: - 监听方法
    /**
     登录
     */
    func loginAction()  {
        
        let oA = WLLOAuthViewController()
        
        presentViewController(UINavigationController(rootViewController: oA), animated: true, completion: nil)
//        print("登录和注册...")
        
    }
    
    override func viewDidLoad() {
        super.viewDidLoad()

           }

     //MARK: - 懒加载控件
    lazy var tableView : UITableView = UITableView()

}
